package com.xinlu.user.bo;

import java.util.Date;

import com.xinlu.common.game.dao.BankBackDao;
import com.xinlu.derek.common.BaseBo;
import com.xinlu.persistence.BankBack;
import com.xinlu.persistence.Users;
import com.xinlu.user.dao.UsersDao;
import com.xinlu.util.tool.DateUtil;

public class ZxczBo extends BaseBo {
	
	/********	Dao注入 Start	*************/
	private UsersDao usersDao;
	
	public void setUsersDao(UsersDao usersDao) {
		this.usersDao = usersDao;
	}
	
	private BankBackDao bankBackDao;
	
	public void setBankBackDao(BankBackDao bankBackDao) {
		this.bankBackDao = bankBackDao;
	}
	
	/********	Dao注入 End	*************/

	public Users userZxcz(String username, String jiner, String bz, String czfs, String account){
		
		Users users = this.usersDao.getUserinfo(username);
		
		if (users == null) {
			
			return null;
		}
		
		double allmoney = users.getAllmoney();
		double addMoney = Double.parseDouble(jiner);
//		users.setAllmoney(users.getAllmoney() + addMoney);
//		users.setUermoney(users.getUermoney() + addMoney);
//		
//		users.setSavetime(DateUtil.getTimestamp(new Date()));
		
//		this.usersDao.update(users);
		
		BankBack instance = new BankBack();
		
		instance.setBBefor(allmoney);
		instance.setBAfter(allmoney + addMoney);
		instance.setBackMoney2(addMoney);
		instance.setBackMoney(0d);
		instance.setState(0);
		instance.setUsername(username);
		instance.setLotteryid("ZXCZ-" + users.getSavetime());
		instance.setType("存款");
		instance.setAddtime(DateUtil.getCurrentDateTimestamp());
		instance.setProstate("正常");
		
		if ("cft".equals(czfs)) {
			
			instance.setFollows(users.getBankName() + "财付通");
		}else if ("zfb".equals(czfs)) {
			
			instance.setFollows(users.getBankName() + "支付宝");
		}else if ("gsyh".equals(czfs)) {
			
			instance.setFollows(users.getBankName() + "工商银行");
			
		}
		
		this.bankBackDao.save(instance);
		
		return users;
	}
	
}
